
const ErrorMessage = require('./errorMessage');
const ErrorCode = require('./errorCode');

class BaseResp {
  constructor(code, message, data) {
    this.code = code;
    this.message = message || ErrorMessage[code] || '系统错误';
    this.data = data;
  }


  static success(data) {
    return new BaseResp(ErrorCode.success, ErrorMessage.success, data);
  }

  static error(code, message) {
    return new BaseResp(code, message || ErrorMessage[code]);
  }
}

module.exports = BaseResp;
